package com.ctshk.rpc.payment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.payment.entity.RefundRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 退款记录 Mapper 接口
 * </p>
 *
 * @author hef
 * @since 2021-05-07
 */
public interface RefundRecordMapper extends BaseMapper<RefundRecord> {

    /**
     * 根据订单号和退款单号查询
     * @param orderNumber
     * @param refundNumber
     * @return
     */
    @Select("SELECT \n" +
            "  * \n" +
            "FROM\n" +
            "  t_refund_record \n" +
            "WHERE order_number = #{orderNumber} \n" +
            "  AND refund_number = #{refundNumber} \n" +
            "  AND is_deleted = 0 " +
            "ORDER BY gmt_create DESC LIMIT 1")
    RefundRecord selectByOrderAndRefundNumber(@Param("orderNumber") String orderNumber,@Param("refundNumber") String refundNumber);


    /**
     * 根据退款单号查询
     * @param refundNumber
     * @return
     */
    @Select("SELECT \n" +
            "  * \n" +
            "FROM\n" +
            "  t_refund_record \n" +
            "WHERE refund_number = #{refundNumber} \n" +
            "  AND is_deleted = 0 " +
            "ORDER BY gmt_create DESC LIMIT 1")
    RefundRecord selectByRefundNumber(@Param("refundNumber") String refundNumber);
}
